package lt.mockos.app.client.cpu.hw.descriptor;

public class ResourceDescriptor implements Descriptor {

    private int ID;
    private String title;
    private ProcessDescriptor parent;
    private ProcessDescriptor usingProcess;
    private Channel channel;

    public enum Channel {
        CPU, EXTERNAL, INPUT, OUTPUT
    }

    public ResourceDescriptor(String title, ProcessDescriptor parent, Channel channel) {
        super();
        this.title = title;
        this.parent = parent;
        this.channel = channel;
    }

    @Override
    public ProcessDescriptor getParent() {
        return parent;
    }

    public ProcessDescriptor getUsingProcess() {
        return usingProcess;
    }

    @Override
    public int getID() {
        return ID;
    }

    public void setID(int iD) {
        ID = iD;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public void setParent(ProcessDescriptor parent) {
        this.parent = parent;
    }

    public void setUsingProcess(ProcessDescriptor usingProcess) {
        this.usingProcess = usingProcess;
    }

    @Override
    public DescriptorType getDescriptorType() {
        return DescriptorType.RESOURCE;
    }

    @Override
    public String toString() {
        return "R:" + "." + ID + "." + title + "." + (parent != null ? parent.getID() + "" : ".") + "." + (usingProcess != null ? usingProcess.getID() + "" : ".") + "."
                + channel.name();
    }

}
